<?php
namespace Home\Controller;
use Think\Controller;
class DataapiController extends Controller {
	public function __call($function_name, $args){
        echo json_encode(array());die;
    }
	
    //大众点评-运动
	public function dianping_sport(){
		$page = I('get.page',1,'intval');
        $pagesize = I('get.size',20,'intval');
        $category = I('get.category','');
        $city = I('get.city',null);
        $district = I('get.district',null);
        if(empty($district) || empty($city)) {
            echo json_encode( array('status'=>1003,'msg'=>'缺少必要参数',data=>null));exit;
        }

        $table = "dianping_sport";
        $sql = "select * from ".$table." where 1=1 ";

        $sql .= " and city = '".$city."' ";
        $sql .= " and district = '".$district."' ";
		if(!empty($category)){
			$sql.=" and categories like '%".$category."%' ";
		}
        
		$sql .= " order by cid ";
		$sql .= " limit ".$pagesize." offset ".($page-1)*$pagesize; 
		
        echo $sql;die;
		$pg_connect = $this->conncetPgsql();
        $result = pg_query($pg_connect,$sql);
        pg_close($pg_connect);
        
        $data = array();
        while($list = pg_fetch_object($result)){
            array_push($data, $list);
        }
        
        echo json_encode(array('status'=>0,'msg'=>'ok','data'=>$data),JSON_UNESCAPED_UNICODE);
	}


}